//
//  MineHeaderView.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/5.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "MineHeaderView.h"

@implementation MineHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}
- (void)setUpUI
{
    WeakSelf
    self.bgImg = [[UIImageView alloc] initWithFrame:self.frame];
    _bgImg.image = UIImageNamed(@"minetopHeader");
    _bgImg.userInteractionEnabled = YES;
    [self addSubview:_bgImg];
    
    // 右按钮
    _rightBtn = [UIButton buttonWithTitle:@"设置  " fontSize:16 titleColor:UIColorWhite background:kClearColor cornerRadius:0];
    [_rightBtn sizeToFit];
    [_bgImg addSubview:_rightBtn];
    [_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.bgImg).offset(TopHeight+10);
        make.right.equalTo(weakSelf.bgImg).offset(-rateWidth(30));
    }];
    
    self.headerImg = [[UIImageView alloc] init];
    _headerImg.image = UIImageNamed(@"touxiang");
    _headerImg.layer.masksToBounds = YES;
    _headerImg.layer.cornerRadius = rateWidth(50);
    _headerImg.backgroundColor = UIColorWhite;
    [self addSubview:_headerImg];
    [_headerImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(rateWidth(100), rateWidth(100)));
        make.left.equalTo(self).offset(rateWidth(30));
        make.bottom.equalTo(self).offset(-rateHeight(30));
    }];
    
    self.nameLB = [UILabel labelWithText:@"会员姓名" textColor:UIColorWhite fontSize:15];
    [_nameLB sizeToFit];
    [self addSubview:_nameLB];
    [_nameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.headerImg.mas_right).offset(rateWidth(20));
        make.centerY.equalTo(weakSelf.headerImg);
    }];
    
    self.gradeImg = [[UIImageView alloc] init];
    _gradeImg.image = UIImageNamed(@"putongHuiYuan");
    [_gradeImg sizeToFit];
    [self addSubview:_gradeImg];
    [_gradeImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.nameLB.mas_right).offset(rateWidth(25));
        make.centerY.equalTo(weakSelf.headerImg);
    }];
    self.gradeLB = [UILabel labelWithText:@"" textColor:UIColorWhite fontSize:11];
    [self.gradeLB sizeToFit];
    [_gradeImg addSubview:_gradeLB];
    [_gradeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(weakSelf.gradeImg);
    }];
    
    self.signBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.signBtn setImage:UIImageNamed(@"qiandao") forState:(UIControlStateNormal)];
    [self.signBtn sizeToFit];
    [self addSubview:_signBtn];
    [_signBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.headerImg);
        make.right.equalTo(self);
    }];
    
}

@end
